package com.fyy.shardingjdbc.controller;

import com.fyy.shardingjdbc.model.User;
import com.fyy.shardingjdbc.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/api")
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/list")
    public List<User> getUserList(User user){
        return userService.selectUserList(user);
    }

    @RequestMapping("/add")
    public String addUser(){
        User user = new User();
        user.setId(3);
        user.setAccount("fyy");
        user.setCreate_time(new Date());
        user.setName("fyy");
        user.setPwd("123456");
        int i = userService.insertUser(user);
        return "操作结果：" + i;
    }

}
